/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package myftp.core.view.listener;

import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import myftp.app.model.ExplorerTreeModel;
import myftp.app.model.ExplorerModel;

/**
 *
 * @author CAVARLE Glenn, LUCAS Stéphane
 * Listener de selection sur les arbres de dossiers
 */
public class FileTreeListener implements TreeSelectionListener {

    public ExplorerModel explorer;

    public FileTreeListener(ExplorerModel anExplorer) {
        super();
        this.explorer = anExplorer;
    }

    public void valueChanged(TreeSelectionEvent e) {
	/* Récupération de l'arbre */
        JTree aTree = (JTree) e.getSource();
	/* Récupération du chemin au dossier */
        ExplorerTreeModel node = (ExplorerTreeModel) aTree.getLastSelectedPathComponent();
        
        if (node == null) {
            return;
        }

	/* Exploration du nouveau dossier */
        explorer.chargement(node);
    }
}

